package Dao;

import bean.check;
import bean.medicine;

import java.util.List;

public class checkDao extends BaseDao{
    public List<check> queryChecks() throws Exception {
        String sql = "SELECT * FROM health_check";
        return queryForList(check.class,sql);
    }

//    上述SQL语句创建一个名为medicine的药品表，其中id字段为自增主键，name为药品名称，
//    code为药品编码，category为药品分类，specification为药品规格，
//    producer为药品产地，price为药品价格，quantity为库存数量。药品表中的每一行代表一个药品。

    public check queryCheckByName(String name) {
        String sql = "SELECT cid,name,drug,office,checkRoom,doctor,checkFee FROM health_check WHERE name = ?";
        try {
            return queryForOne(check.class,sql,name);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public List<check> queryCheckByOffice(String office) {
        String sql = "SELECT cid,name,drug,office,checkRoom,doctor,checkFee FROM health_check WHERE office = ?";
        try {
            return queryForList(check.class,sql,office);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    public check queryCheckById(String cid) {
        String sql = "SELECT cid,name,drug,office,checkRoom,doctor,checkFee FROM health_check WHERE cid = ?";
        try {
            return queryForOne(check.class,sql,cid);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
